import { createRouter, createWebHistory } from 'vue-router'

import Blog from '@/views/Blog.vue'
import BlogDetail from '@/views/BlogDetail.vue'
import Home from '@/views/Home.vue'
import Hotel from '@/views/Hotel.vue'
import HotelDetail from '@/views/HotelDetail.vue'
import HotelOptionEmpty from '@/views/HotelOptionEmpty.vue'
import HotelSearch from '@/views/HotelSearch.vue'
import Layout from '@/views/Layout.vue'
import Search from '@/views/Search.vue'
import Ticket from '@/views/Ticket.vue'
import Tour from '@/views/Tour.vue'
import User from '@/views/User.vue'
import UserBlog from '@/views/UserBlog.vue'
import UserOrder from '@/views/UserOrder.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      redirect: '/home',
      children: [
        { path: 'home', component: Home },
        { path: 'search/:keyword?', component: Search },
        { path: 'hotel', component: Hotel },
        { path: 'hotel/search/:city/:price?/:rate?', component: HotelSearch },
        { path: 'hotel/detail/:id?', component: HotelDetail }, //TODO remove the ?
        { path: 'HotelOptionEmpty', component: HotelOptionEmpty },
        { path: 'tour', component: Tour },
        { path: 'ticket', component: Ticket },
        { path: 'blog', component: Blog },
        { path:'blog/detail/:id', component: BlogDetail},
        {
          path: 'user',
          component: User,
          redirect:'/user/blog',
          children:[
            {path:'order', component: UserOrder},
            {path:'blog', component: UserBlog},
          ]
        }
      ]
    }
  ]
})

// TODO route guard

export default router
